package bigoo.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class Config {

    public final static String BIGOO_PROPERTIES = "bigoo.properties";

    // Properties keys and default values
    public static String LOG_LEVEL_PROP = "log.level";
    private static String LOG_LEVEL_DEFAULT = "FINEST";
    public static String LOG_FILE_PROP = "log.file";
    public static String PROPAGATION_PROTOCOL = "propagation.protocol";
    public static String EPIDEMIC_INTERVAL = "epidemic.interval";
    public static String PEERS = "peers";
    public static String TAXA_BUSCA = "searcher.rate";
    public static String TAXA_PUBLICA = "publisher.rate";
    public static String TEMPO_SIMULACAO = "simulation.time";
    public static String NETWORK_DELAY = "network.delay";
    public static String PROCESS_DELAY = "process.delay";

    private static Properties props = null;

    public static String getProperty(String property) {
	return getProperties().getProperty(property);
    }

    public synchronized static Properties getProperties() {
	if (props == null) {
	    loadProperties();
	}
	return props;
    }

    private static void loadProperties() {
	try {
	    props = new Properties();
	    props.load(new FileInputStream(BIGOO_PROPERTIES));
	} catch (IOException ioex) {
	    System.err.println("Properties file not found, ABORTING!!!");
	    System.exit(-1);
	}
    }
}
